package cn.tx.service.impl;

import cn.tx.entity.PageResult;
import cn.tx.mapper.CheckItemDao;
import cn.tx.pojo.CheckItem;
import cn.tx.service.CheckItemService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Snake Eyes
 * @PROJECT_NAME: health_parent
 * @DESCRIPTION:
 * @USER: 11647
 * @DATE: 2021/8/25 21:36
 * @Email: 1164763541@qq.com
 */
@Service(interfaceClass = CheckItemService.class)
@Transactional
public class CheckItemServiceImpl implements CheckItemService {
    @Autowired
    private CheckItemDao checkItemDao;

    @Override
    public List<CheckItem> findAll() {
        return checkItemDao.findAll();
    }

    @Override
    public void save(CheckItem checkItem) {
        checkItemDao.save(checkItem);
    }


    /**
     * @return
     * @author :11647
     * @date ：Created in 2021/8/26  9:43
     * @description：(描述) 检查项分页查询
     * @modified By：11647
     * @version:
     */
    @Override
    public PageResult findPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage, pageSize);
        Page<CheckItem> page = checkItemDao.findPage(queryString);
        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public void deleteById(Integer id) {
        checkItemDao.deleteById(id);
    }

    @Override
    public void updateById(CheckItem checkItem) {
        checkItemDao.updateById(checkItem);

    }

}
